<?php	
	include_once("../includes/common.php");
	array_shift($url); //strip off /admin/
	
	//authenticate login
	if(!isset($_SESSION['loggedin'])) {
		header("Location: ".HTTP_SERVER);
		exit;
	}
	
	//include chat script
	/*
	include_once(FILE_SERVER.ADMIN_DIR."chat/src/phpfreechat.class.php");
	$params = array("title" => "SA Blog Awards Panel Chat",
									"nick" => "".$_SESSION['loggedin'],
									"isadmin" => true, 
									"frozen_nick" => true,
									"showsmileys" => false,
									"height" => "250px",
									"serverid" => md5(__FILE__));
	$chat = new phpFreeChat( $params );
	*/
	switch ($url[0]) {
		case 'categories':
			include_once("../".SERVER_DIR.ADMIN_DIR."categories.php");
			//$js .= "<script type='text/javascript' src='".HTTP_SERVER.SCRIPT_DIR.ADMIN_DIR."categories.js'></script>";
			break;
		case 'contestants':
			include_once("../".SERVER_DIR.ADMIN_DIR."contestants.php");
			//$js .= "<script type='text/javascript' src='".HTTP_SERVER.SCRIPT_DIR.ADMIN_DIR."contestants.js'></script>";
			break;
		case 'members':
			include_once("../".SERVER_DIR.ADMIN_DIR."members.php");
			//$js .= "<script type='text/javascript' src='".HTTP_SERVER.SCRIPT_DIR.ADMIN_DIR."members.js'></script>";
			break;
		case 'member_votes':
			break;
		case 'profile':
			include_once("../".SERVER_DIR.ADMIN_DIR."details.php");
			//$js .= "<script type='text/javascript' src='".HTTP_SERVER.SCRIPT_DIR.ADMIN_DIR."details.js'></script>";
			break;
		case 'standings':
			//currently not optimised for ease of use or ajax, but can add that later
			break;
		case 'nominations':
			if(!isset($url[1]) || $url[1]=='') $url[1] = 'group';
			include_once("../".SERVER_DIR.ADMIN_DIR."nominations.php");
			$js .= "<script type='text/javascript' src='".HTTP_SERVER.SCRIPT_DIR.ADMIN_DIR."nominations.js'></script>";
			break;
		case 'logout':
			include("../logout.php");
			exit;
			break;
		case 'update':
			//will become obsolete when url checking implemented on nomination submission
			break;
		default:
			header("Location: ".HTTP_SERVER.ADMIN_DIR."nominations");
			break;
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><?php echo CONTEST_NAME; ?> Admin</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="objecttype" content="Document" />
	<meta name="author" content="Miguel dos Santos" />
	<?php echo $js; ?>
	<?php echo $styles; ?>
	<?php /*$chat->printJavascript();*/ ?>
  <?php /*$chat->printStyle();*/ ?> 
</head>
<body>
	<noscript><style type='text/css'>.hideme { display:block; } .spinner {display:none;}</style></noscript>
	<?php				
		include("../top.php");
		echo "<div id='content'>";
		switch($url[0]) {
			case 'categories':
				include_once("categories.php");
				break;
			case 'contestants':
				include_once("contestants.php");
				break;
			case 'members':
				include_once("members.php");
				break;
			case 'member_votes':
				include_once("member_vote.php");
				break;
			case 'profile':
				include_once("details.php");
				break;
			case 'standings':
				include_once("standings.php");
				break;
			case 'nominations':
				include_once("nominations.php");
				break;
			case 'update':
				include_once("update.php");
				break;
			default: break;
		}
		echo "</div>";
		include("../footer.php"); 
	?>
</body>
</html>
